// import com.alibaba.druid.DbType;
// import com.alibaba.druid.sql.ast.SQLName;
// import com.alibaba.druid.sql.ast.SQLStatement;
// import com.alibaba.druid.sql.ast.statement.SQLCreateStatement;
// import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "OracleCreatePackageStatement.h"
#include "../../../../../DbType.h"
#include "../../../../ast/SQLName.h"
#include "../../../../ast/SQLStatement.h"
#include "../../visitor/OracleASTVisitor.h"
#include "../../../../../utils/listTran.h"

OracleCreatePackageStatement::OracleCreatePackageStatement()
{
  OracleCreatePackageStatement::setDbType(DbType_ptr(new DbType(&DbType::oracle)));
  statements = std::make_shared<std::list<SQLStatement_ptr>>();
}

// @Override
void OracleCreatePackageStatement::accept0(OracleASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(OracleCreatePackageStatement)))
  {
    acceptChild(visitor, name);
    SQLObject_list_ptr tmp1 = ListTran::tran_class<SQLStatement, SQLObject>(statements);
    acceptChild(visitor, tmp1);
  }
  visitor->endVisit(SharedObject(OracleCreatePackageStatement));
}

SQLObject_ptr OracleCreatePackageStatement::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<OracleCreatePackageStatement>(new OracleCreatePackageStatement());
  std::shared_ptr<OracleCreatePackageStatement> x = std::dynamic_pointer_cast<OracleCreatePackageStatement>(clone_tmp);
  // OracleCreatePackageStatement x = new OracleCreatePackageStatement();

  x->orReplace = orReplace;
  if (name != nullptr)
  {
    x->setName(std::dynamic_pointer_cast<SQLName>(name->clone()));
  }
  x->body = body;

  for (SQLStatement_ptr stmt : *statements)
  {
    SQLStatement_ptr s2 = std::dynamic_pointer_cast<SQLStatement>(stmt->clone());
    s2->setParent(x);
    x->statements->push_back(s2);
  }

  return x;
}

BOOL_ptr OracleCreatePackageStatement::isOrReplace()
{
  return orReplace;
}

void OracleCreatePackageStatement::setOrReplace(BOOL_ptr orReplace)
{
  this->orReplace = orReplace;
}

BOOL_ptr OracleCreatePackageStatement::isBody()
{
  return body;
}

void OracleCreatePackageStatement::setBody(BOOL_ptr body)
{
  this->body = body;
}

SQLName_ptr OracleCreatePackageStatement::getName()
{
  return name;
}

void OracleCreatePackageStatement::setName(SQLName_ptr name)
{
  if (name != nullptr)
  {
    name->setParent(SharedObject(OracleCreatePackageStatement));
  }
  this->name = name;
}

SQLStatement_list_ptr OracleCreatePackageStatement::getStatements()
{
  return statements;
}
